package com.dzsw.javabase.environment;

import java.io.IOException;
import java.io.InputStream;

public class ResourceSample {

    public static void main(String[] args) throws IOException {
        // base path
        System.out.println(System.getProperty("user.dir"));
        // classes path
        String path = ResourceSample.class.getClassLoader().getResource("").getPath();
        System.out.println(path);
        // get class path file
        InputStream in = ResourceSample.class.getClassLoader().getResourceAsStream("log4j2.xml");
        byte[] buff = new byte[1024];
        int len;
        while ((len = in.read(buff)) > 0) {
            System.out.write(buff, 0, len);
        }
    }
}
